package com.acwing.partition11;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

/**
 * @author `RKC`
 * @date 2021/12/24 15:48
 */
public class AC1083Windy数 {

    private static final int N = 11;
    //dp[i][j]表示最高位是i，总长度是j的满足windy数性质的数量
    private static int[][] dp = new int[10][N];

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        init();
        String[] s = reader.readLine().split("\\s+");
        int x = Integer.parseInt(s[0]), y = Integer.parseInt(s[1]);
        writer.write((resolve(y) - resolve(x - 1)) + "\n");
        writer.flush();
    }

    private static void init() {
        for (int i = 0; i <= 9; i++) dp[i][1] = 1;
        for (int length = 2; length < N; length++) {
            for (int i = 0; i <= 9; i++) {
                for (int j = 0; j <= 9; j++) {
                    if (Math.abs(j - i) < 2) continue;
                    dp[i][length] += dp[j][length - 1];
                }
            }
        }
    }

    private static int resolve(int num) {
        if (num == 0) return 0;
        List<Integer> nums = new ArrayList<>();
        while (num != 0) {
            nums.add(num % 10);
            num /= 10;
        }
        //因为windy数的性质，last需要和0到9的所有数至少相差2
        int answer = 0, last = -2;
        for (int i = nums.size() - 1; i >= 0; i--) {
            int x = nums.get(i);
            //因为不能计算前导0，因此在枚举最高位的时候，需要从1开始，而枚举其它位的时候，可以从0开始
            for (int j = i == nums.size() - 1 ? 1 : 0; j < x; j++) {
                if (Math.abs(j - last) >= 2) answer += dp[j][i + 1];
            }
            //只有相差大于2才保存上一位，否则不是一个合法的windy数
            if (Math.abs(x - last) < 2) break;
            last = x;
            if (i == 0) answer++;
        }
        //前导零的数在之前的处理被跳过，这里单独处理含有前导零的
        for (int length = 1; length < nums.size(); length++) {
            for (int i = 1; i <= 9; i++) {
                answer += dp[i][length];
            }
        }
        return answer;
    }
}
